<?php


namespace app\common\model;


use think\Model;

class UserWalletDeal extends Model
{
    protected $pk = "id";
    // 定义时间戳字段名
    protected $createTime = 'add_time';
    //修改format类型
    protected $dateFormat = "Y-m-d H:i:s";
    protected $type = [
        'money'     => 'float',
        'jy_sxf'     => 'float',
        'jy_price'     => 'float',
        'amount'     => 'float',
    ];
    public function getPkAttr($value,$data) {
        return $this->pk;
    }
    public function user(){
        return $this->hasOne(Users::class, 'user_id','user_id');
    }
    public function duser(){
        return $this->hasOne(Users::class, 'user_id','d_user_id');
    }
    public function qianbao(){
        return $this->hasOne(Wallet::class, 'id','wid');
    }
    public function getEndTimeTextAttr($value,$data) {
        if ($data['end_time']){
            return date($this->dateFormat,$data['end_time']);
        }
        return '---';
    }
    public function getStatusTextAttr($value,$data) {
        $types = [-1=>'出售中',1=>'已完成',2=>'已完成',3=>'已取消'];
        return $types[$data['status']];
    }
}
